// ignore_for_file: unused_element, non_constant_identifier_names

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:verse_systems/commom/config/config.dart';
import 'package:verse_systems/commom/models/aboutus_model.dart';
import 'package:verse_systems/pages/mine/mine_control.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/utils/image_utils.dart';
import 'package:verse_systems/widgets/drawer_appbar.dart';

class MieAboutUsPage extends StatefulWidget {
  const MieAboutUsPage({super.key});

  @override
  State<MieAboutUsPage> createState() => _MieAboutUsPageState();
}

class _MieAboutUsPageState extends State<MieAboutUsPage> {
  final control = Get.find<MineControl>();
  final state = Get.find<MineControl>().state;

  @override
  void initState() {
    super.initState();
    control.getAboutInfo();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colours.system_background_color,
        body: GetBuilder<MineControl>(
            init: control,
            builder: (_) {
              return SizedBox(
                height: MediaQuery.of(context).size.height,
                child: Stack(
                  children: [_aboutUs, _aboutContent],
                ),
              );
            }));
  }

  Widget get _aboutContent {
    return Positioned(
        top: 220.w,
        child: Container(
          padding: EdgeInsets.symmetric(vertical: 38.w, horizontal: 15.w),
          height: 500.w,
          margin: EdgeInsets.symmetric(
              horizontal: (MediaQuery.of(context).size.width - 330.w) / 2,
              vertical: 15.w),
          width: 330.w,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.all(Radius.circular(10.w)),
            color: Colours.app_main_color,
          ),
          child: SingleChildScrollView(
            child: Column(
              children: _about_content,
            ),
          ),
        ));
  }

  List<Widget> get _about_content {
    return state.content.map((AboutUsModel model) {
      return Column(
        children: [
          Row(
            children: [
              Container(
                width: 7.w,
                height: 18.w,
                color: Colours.app_main_background_color,
              ),
              SizedBox(width: 8.w),
              Text(
                model.title.toString(),
                style: TextStyle(
                    fontSize: 18.sp,
                    color: Colours.app_black_text_color,
                    fontWeight: FontWeight.w500,
                    height: 1.5),
              ),
            ],
          ),
          SizedBox(height: 9.w),
          Text(
            model.content.toString(),
            style: TextStyle(
              fontSize: 14.sp,
              color: Colours.calendar_open_text_color,
            ),
          ),
          SizedBox(height: 26.w),
        ],
      );
    }).toList();
  }

  Widget get _aboutUs {
    return Container(
      height: 300.w,
      decoration: BoxDecoration(
        image: DecorationImage(
            image: ExactAssetImage(ImageUtils.getImgPath("loan_background")),
            fit: BoxFit.fill),
      ),
      child: Column(
        children: [
          DrawerAppbar(
            backgroundColor: Colors.transparent,
            color: Colours.app_main_color,
            title: 'about_us'.tr,
          ),
          Container(
              width: 60.w,
              height: 60.w,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(15.w)),
                image: DecorationImage(
                    image: ExactAssetImage(
                        ImageUtils.getImgPath(Config.getConfigLogo())),
                    fit: BoxFit.fill),
              )),
          SizedBox(height: 20.w),
          Text(
            "${Config.getConfigPage()}${"loan".tr}",
            style: TextStyle(
                fontSize: 20.sp,
                color: Colours.app_main_color,
                fontWeight: FontWeight.w600,
                height: 1.5),
          ),
          Text(
            "finance_services_platform".tr,
            style: TextStyle(fontSize: 14.sp, color: Colours.app_main_color),
          ),
        ],
      ),
    );
  }
}
